﻿using GSPatEditor.Bitmaps;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GSPatEditor.Pat
{
    abstract class Image
    {
        private class EmptyImage : Image
        {
            public override Bitmap CreateBitmapWithPalette(Palette pal)
            {
                throw new NotImplementedException();
            }
        }

        public static readonly Image Empty = new EmptyImage();

        public static Image CreateFromFile(string filename, string resName)
        {
            var ext = Path.GetExtension(filename);
            if (ext == ".bmp")
            {
                var ret = CV2File.CreateCV2FromFile(Path.ChangeExtension(filename, ".cv2"));
                ret.ResourceName = resName;
                return ret;
            }
            else if (ext == ".dds")
            {
                var ret = DDSFile.CreateDDSFromFile(filename);
                ret.ResourceName = resName;
                return ret;
            }
            return Empty;
        }

        public abstract Bitmap CreateBitmapWithPalette(Palette pal);

        public string ResourceName { get; private set; }
        public int Height { get; protected set; }
        public int Width { get; protected set; }
    }
}
